/*
 *
 * Copyright 2019-2020,2022-2024 NXP.
 *
 * NXP Confidential. This software is owned or controlled by NXP and may only be
 * used strictly in accordance with the applicable license terms. By expressly
 * accepting such terms or by downloading,installing, activating and/or otherwise
 * using the software, you are agreeing that you have read,and that you agree to
 * comply with and are bound by, such license terms. If you do not agree to be
 * bound by the applicable license terms, then you may not retain, install, activate
 * or otherwise use the software.
 *
 */

/**
 *
 *  This file contains the definition from UCI specification
 *
 */

#ifndef UWB_UCI_EXT_DEFS_H
#define UWB_UCI_EXT_DEFS_H

#include <stdint.h>

/**
 *     Device Information Parameters
 */
#define UCI_EXT_PARAM_ID_DEVICE_NAME      0xE3
#define UCI_EXT_PARAM_ID_FIRMWARE_VERSION 0xE4
#define UCI_EXT_PARAM_ID_DEVICE_VERSION   0xE5
#define UCI_EXT_PARAM_ID_SERIAL_NUMBER    0xE6
#define UCI_EXT_PARAM_ID_DSP_VERSION      0xE7
#define UCI_EXT_PARAM_ID_RANGER4_VERSION  0xE8
#define UCI_EXT_PARAM_ID_CCC_VERSION      0xE9

#define UCI_EXT_PARAM_ID_DEVICE_NAME_LEN      0x08
#define UCI_EXT_PARAM_ID_FIRMWARE_VERSION_LEN 0x03
#define UCI_EXT_PARAM_ID_DEVICE_VERSION_LEN   0x02
#define UCI_EXT_PARAM_ID_SERIAL_NUMBER_LEN    0x08
#define UCI_EXT_PARAM_ID_DSP_VERSION_LEN      0x03
#define UCI_EXT_PARAM_ID_RANGER4_VERSION_LEN  0x02
#define UCI_EXT_PARAM_ID_CCC_VERSION_LEN      0x08

/* R4 Specific Commands */
#define EXT_UCI_MSG_LOG_NTF                    0x00
#define EXT_UCI_MSG_RADIO_CONFIG_DOWNLOAD_CMD  0x11
#define EXT_UCI_MSG_ACTIVATE_SWUP_CMD          0x12
#define EXT_UCI_MSG_TEST_START_CMD             0x20
#define EXT_UCI_MSG_TEST_STOP_CMD              0x21
#define EXT_UCI_MSG_STACK_TEST_CMD             0x23
#define EXT_UCI_MSG_DEVICE_SUSPEND_CMD         0x24
#define EXT_UCI_MSG_TEST_LOOPBACK_NTF          0x25
#define EXT_UCI_MSG_SET_TRIM_VALUES_CMD        0x26
#define EXT_UCI_MSG_GET_ALL_UWB_SESSIONS       0x27
#define EXT_UCI_MSG_GET_TRIM_VALUES_CMD        0x28
#define EXT_UCI_MSG_SESSION_NVM_MANAGE_CMD     0x2B
#define EXT_UCI_MSG_GET_LUT_CRC                0x2C
#define EXT_UCI_MSG_GET_TRNG                   0x2D
#define EXT_UCI_MSG_SET_PROFILE                0x2E
#define EXT_UCI_MSG_BYPASS_CURRENT_LIMITER_CMD 0x2F
#define EXT_PSDU_LOG_NTF                       0x31

/**
 * UCI Extention Parameter IDs : Device Configurations
 */
/* Core Device Configurations */
#define UCI_EXT_PARAM_ID_DPD_ENTRY_TIMEOUT           0xE9
#define UCI_EXT_PARAM_ID_HPD_ENTRY_TIMEOUT           0xEA
#define UCI_EXT_PARAM_ID_MHR_IN_CCM                  0xF9
#define UCI_EXT_PARAM_ID_DDFS_TONE_CONFIG_ENABLE     0xFA
#define UCI_EXT_PARAM_ID_NXP_EXTENDED_NTF_CONFIG     0xFB
#define UCI_EXT_PARAM_ID_DPD_ENTRY_TIMEOUT_LEN       0x02
#define UCI_EXT_PARAM_ID_HPD_ENTRY_TIMEOUT_LEN       0x02
#define UCI_EXT_PARAM_ID_DDFS_TONE_CONFIG_LEN        0x01
#define UCI_EXT_PARAM_ID_MHR_IN_CCM_LEN              0x01
#define UCI_EXT_PARAM_ID_NXP_EXTENDED_NTF_CONFIG_LEN 0x01

/* R4 Proprietary Application Configurations */
#define UCI_EXT_PARAM_ID_ADAPTIVE_HOPPING_THRESHOLD 0xB0
#define UCI_EXT_PARAM_ID_MAC_CFG                    0xB1
#define UCI_EXT_PARAM_ID_ANTENNA_CONFIG             0XB2
#define UCI_EXT_PARAM_ID_ULTDOA_MAC_FRAME_FORMAT    0xB3
#define UCI_EXT_PARAM_ID_RANGING_START_OFFSET       0xB4
#define UCI_EXT_PARAM_ID_RX_START_MARGIN_ID         0xE3
#define UCI_EXT_PARAM_ID_RX_TIMEOUT_ID              0xE4
#define UCI_EXT_PARAM_ID_NBIC_CONF_ID               0xE6
#define UCI_EXT_PARAM_ID_M_UPSK                     0xEB
#define UCI_EXT_PARAM_ID_SALTED_HASH                0xEC
#define UCI_EXT_PARAM_ID_D_URSK                     0xED
#define UCI_EXT_PARAM_ID_D_UDSK                     0xEE
#define UCI_EXT_PARAM_ID_TX_POWER_ID                0xF2
#define UCI_EXT_PARAM_ID_DEBUG_LOG_LEVEL            0xF3
#define UCI_EXT_PARAM_ID_RX_PHY_LOGGING_ENBL        0xF4
#define UCI_EXT_PARAM_ID_TX_PHY_LOGGING_ENBL        0xF5
#define UCI_EXT_PARAM_ID_LOG_PARAMS_CONF            0xF6
#define UCI_EXT_PARAM_ID_CIR_TAP_OFFSET             0xF7
#define UCI_EXT_PARAM_ID_CIR_NUM_TAPS               0xF8
#define UCI_EXT_PARAM_ID_STS_INDEX_RESTART          0xF9
#define UCI_EXT_PARAM_ID_RX_RADIO_CFG_IDXS          0xFB
#define UCI_EXT_PARAM_ID_TX_RADIO_CFG_IDXS          0xFC
#define UCI_EXT_PARAM_ID_CRYPTO_KEY_USAGE_FLAG      0xFD

/* Length of R4 Proprietary Application Configurations */
#define UCI_EXT_PARAM_ID_M_UPSK_LEN                  0x11
#define UCI_EXT_PARAM_ID_SALTED_HASH_LEN             0x11
#define UCI_EXT_PARAM_ID_D_URSK_LEN                  0x11
#define UCI_EXT_PARAM_ID_D_UDSK_LEN                  0x11
#define UCI_EXT_PARAM_ID_NBIC_CONF_ID_LEN            0x01
#define UCI_EXT_PARAM_ID_TX_POWER_ID_LEN             0x01
#define UCI_EXT_PARAM_ID_DEBUG_LOG_LEVEL_LEN         0x01
#define UCI_EXT_PARAM_ID_RX_PHY_LOGGING_ENBL_LEN     0x01
#define UCI_EXT_PARAM_ID_TX_PHY_LOGGING_ENBL_LEN     0x01
#define UCI_EXT_PARAM_ID_LOG_PARAMS_CONF_LEN         0x04
#define UCI_EXT_PARAM_ID_CIR_TAP_OFFSET_LEN          0x02
#define UCI_EXT_PARAM_ID_CIR_NUM_TAPS_LEN            0x02
#define UCI_EXT_PARAM_ID_STS_INDEX_RESTART_LEN       0x01
#define UCI_EXT_PARAM_ID_RX_RADIO_CFG_IDXS_LEN       0x02
#define UCI_EXT_PARAM_ID_TX_RADIO_CFG_IDXS_LEN       0x02
#define UCI_EXT_PARAM_ID_CRYPTO_KEY_USAGE_FLAG_LEN   0x01
#define UCI_EXT_PARAM_ID_DDFS_TONE_CONFIG_ENABLE_LEN 0x01

#define UCI_EXT_TEST_MODE_RECEIVE_MODE            0x00
#define UCI_EXT_TEST_MODE_TRANSMIT_MODE           0x01
#define UCI_EXT_TEST_MODE_CONTINUOUS_WAVE_MODE    0x02
#define UCI_EXT_TEST_MODE_LOOP_BACK_MODE          0x03
#define UCI_EXT_TEST_MODE_LOOP_BACK_AND_SAVE_MODE 0x05

#define UCI_EXT_RECEIVE_MODE_NO_OF_PARAMS         0x07
#define UCI_EXT_TRANSMIT_MODE_NO_OF_PARAMS        0x07
#define UCI_EXT_CONTINUOUS_WAVE_MODE_NO_OF_PARAMS 0x01
#define UCI_EXT_LOOP_BACK_MODE_NO_OF_PARAMS       0x01
#define UCI_EXT_SSTWR_MODE_NO_OF_PARAMS           0x00

#define UCI_EXT_TEST_MODE_ID_TEST_MODE         0x00
#define UCI_EXT_TEST_MODE_ID_DELAY             0x01
#define UCI_EXT_TEST_MODE_ID_SLOT_TYPE         0x02
#define UCI_EXT_TEST_MODE_ID_PSDU              0x03
#define UCI_EXT_TEST_MODE_ID_TIME_OUT          0x04
#define UCI_EXT_TEST_MODE_ID_EVENT_COUNTER_MAX 0x05
#define UCI_EXT_TEST_MODE_ID_CYCLE_TIME        0x06
#define UCI_EXT_TEST_MODE_ID_ENCRYPTED_PSDU    0x07
#define UCI_EXT_TEST_MODE_ID_PHR_RANGING_BIT   0x09

#define UCI_EXT_TEST_MODE_ID_TEST_MODE_LEN         0x01
#define UCI_EXT_TEST_MODE_ID_DELAY_LEN             0x02
#define UCI_EXT_TEST_MODE_ID_SLOT_TYPE_LEN         0x01
#define UCI_EXT_TEST_MODE_ID_TIME_OUT_LEN          0x02
#define UCI_EXT_TEST_MODE_ID_EVENT_COUNTER_MAX_LEN 0x04
#define UCI_EXT_TEST_MODE_ID_CYCLE_TIME_LEN        0x04
#define UCI_EXT_TEST_MODE_ID_ENCRYPTED_PSDU_LEN    0x01
#define UCI_EXT_TEST_MODE_ID_PHR_RANGING_BIT_LEN   0x01

#define UCI_EXT_TEST_MODE_ID_EXTENDED_PSDU_FRAME1 0x0A /** Frame 1 Extended Payload byte[0, 254] for Transmit Mode */
#define UCI_EXT_TEST_MODE_ID_EXTENDED_PSDU_FRAME2 0x0B /** Frame 2 Extended Payload byte[255-509]for Transmit Mode */
#define UCI_EXT_TEST_MODE_ID_EXTENDED_PSDU_FRAME3 0x0C /** Frame 3 Extended Payload  byte[510-764] for Transmit Mode \
                                                        */
#define UCI_EXT_TEST_MODE_ID_EXTENDED_PSDU_FRAME4 0x0D /** Frame 4 Extended Payload  byte[765-1019] for Transmit Mode \
                                                        */
#define UCI_EXT_TEST_MODE_ID_EXTENDED_PSDU_FRAME5 \
    0x0E /** Frame 5 Extended Payload for byte[1020-1022] for Transmit Mode */

#define UCI_EXT_TEST_MODE_ID_EXTENDED_PSDU_FRAME_LEN 0x01 /** Frame Length for Extended Payload **/
#define EXTENDED_PSDU_FRAME_MAX_SIZE_HPRF            0xFD /** Max Frame Size for Extended Payload**/
#define BPRF_MAX_PSDU_FRAME_SIZE                     0x7F /** Max frame size for bprf psdu **/

/*max psdu supported in single test start cmd greater than this value send remaining PSDU in tag value*/
#define MAX_HPRF_PSDU_DATA_PACKET_SIZE 0x400U

/* Session State codes, as per UCI*/
/** Session State - Session status notification with in band stop received error */
#define UCI_SESSION_IN_BAND_STOP_RECEIVED 0x84

#endif /* UWB_UCI_EXT_DEFS_H */
